/**
 * @param {number} x
 * @return {number}
 */
var reverse = function (x) {
  var minn = - (1 << 30) * 2;
  var maxn = (1 << 30) * 2 - 1;
  var ans;
  var arr = x.toString().split('');
  if (x < 0)
    arr.shift();  // remove '-'
  ans = Number(arr.reverse().join(''));
  if (x < 0)
    ans *= -1;
  if (ans < minn || ans > maxn)
    return 0;
  else
    return ans;
};

/**
 * 字符串数组反转
 * @param {string[]} s 
 * @returns 
 */
var reverseString = function (s) {
  //判断输入的字符串是否为空
  if (s.length == 0) return s;
  //定义两个指针
  let low = 0;
  let high = s.length - 1;
  // 循环反转字符
  while (true) {
    // 分为奇数/偶数两种可能
    if (low === high || high + 1 === low) break;
    let temp = s[low];
    console.log(temp)
    s[low] = s[high];
    s[high] = temp;
    low++;
    high--;
  }
  console.log(s)
  // 返回反转好的字符串
  return s;
};

console.log(reverseString(["h", "e", "l", "l", "o"]))